<template>
	<view class="content">
		<view class="text-area">
			<text class="title">{{title}}</text>
		</view>
		<button type="default" @click="goPay()">点我前去支付</button>
		<button type="default" @click="login()">退款</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: '跟我去支付'
			}
		},
		onLoad() {

		},
		methods: {
			goPay() {
				uni.request({
					url: 'https://116.62.47.169:8889/create/IndentPayment',
					method: 'GET',
					data:{
						openId:"o20577VSU1C9oJVc-x7F1ojJzp2Y",
					},
					success(res) {
						console.log(res);
						console.log(res.data.data.nonceStr),
						wx.requestPayment({
							nonceStr: res.data.data.nonceStr,
							package: res.data.data.packageVal,
							paySign: res.data.data.paySign,
							prepayid: res.data.data.prepayId,
							timeStamp: res.data.data.timeStamp,
							signType: res.data.data.signType,
							success(res) {
								uni.showModal({
									content: "支付成功",
									showCancel: false
								})
								console.log(res);
							},
							fail(e) {
								uni.showModal({
									content: "支付失败,原因为: " + e.errMsg,
									showCancel: false
								})
								console.log(e.errMsg);
							},
							complete() {
								console.log("啥也没干");
							}
						});

					}
				})

			},
			login(){
				uni.request({
					url: 'https://116.62.47.169:8889/refund/IndentPayment',
					// url: 'https://www.wwhlovejr.com.cn:8889/foodCombo/userQueryAllFoodCombo',
					// url: 'https://116.62.47.169:8889/foodCombo/userQueryAllFoodCombo',
					method: 'GET',
					data:{
						orderId:'a964bc4bc0a44dcc814aba66748595dc',
						amount: 0.01,
					},
					success(res) {
						console.log(res);
					}
				})
			}
		}
	}
</script>

<style>
	page {
		background-color: #ff5500;
	}

	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>
